package com.hospital.workstation.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.hospital.common.annotation.RepeatSubmit;
import com.hospital.common.annotation.Log;
import com.hospital.common.core.controller.BaseController;
import com.hospital.common.core.domain.PageQuery;
import com.hospital.common.core.domain.R;
import com.hospital.common.core.validate.AddGroup;
import com.hospital.common.core.validate.EditGroup;
import com.hospital.common.core.validate.QueryGroup;
import com.hospital.common.enums.BusinessType;
import com.hospital.common.utils.poi.ExcelUtil;
import com.hospital.workstation.domain.vo.HisAdmittingDiagInfoVo;
import com.hospital.workstation.domain.bo.HisAdmittingDiagInfoBo;
import com.hospital.workstation.service.IHisAdmittingDiagInfoService;
import com.hospital.common.core.page.TableDataInfo;

/**
 * 诊断信息
 *
 * @author whb
 * @date 2023-03-07
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/workstation/admittingDiagInfo")
public class HisAdmittingDiagInfoController extends BaseController {

    private final IHisAdmittingDiagInfoService iHisAdmittingDiagInfoService;

    /**
     * 查询诊断信息列表
     */
    /*@SaCheckPermission("workstation:admittingDiagInfo:list")
    @GetMapping("/list")
    public TableDataInfo<HisAdmittingDiagInfoVo> list(HisAdmittingDiagInfoBo bo, PageQuery pageQuery) {
        return iHisAdmittingDiagInfoService.queryPageList(bo, pageQuery);
    }*/

    /**
     * 查询诊断信息列表
     *
     * @param bo 诊断信息业务对象
     * @return
     */
    @SaCheckPermission("workstation:admittingDiagInfo:list")
    @GetMapping("/list")
    public R<List<HisAdmittingDiagInfoVo>> queryAdmittingDiagInfoList(HisAdmittingDiagInfoBo bo) {
        return iHisAdmittingDiagInfoService.queryDiagList(bo);
    }

    /**
     * 新增诊断信息
     */
    @SaCheckPermission("workstation:admittingDiagInfo:add")
    @Log(title = "诊断信息", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HisAdmittingDiagInfoBo bo) {
        return toAjax(iHisAdmittingDiagInfoService.insertByBo(bo));
    }

    /**
     * 修改诊断信息
     */
    @SaCheckPermission("workstation:admittingDiagInfo:edit")
    @Log(title = "诊断信息", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HisAdmittingDiagInfoBo bo) {
        return toAjax(iHisAdmittingDiagInfoService.updateByBo(bo));
    }

    /**
     * 删除诊断信息
     *
     * @param ids 主键串
     */
    @SaCheckPermission("workstation:admittingDiagInfo:remove")
    @Log(title = "诊断信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(iHisAdmittingDiagInfoService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
